import xbmc, xbmcaddon
import os, time
import socket
import service
#import asyncore

# Script constants
__addon__       = "Dummy"
__addon_id__    = "service.xbmc-dummy"
__author__      = "N.K."

ip='192.168.178.1'
port = 1012
backlog = 5
size = 1024
xbmc.log("DUMMY Started")


server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.bind((ip,port))
server.listen(backlog)
input = [server,sys.stdin]

while (not xbmc.abortRequested):
    inputready,outputready,exceptready = select.select(input,[],[])

    for s in inputready:

        if s == server:
            # handle the server socket
            client, address = server.accept()
            input.append(client)

        else:
            # handle all other sockets
            data = s.recv(size)
            if data:
                print data
            else:
                s.close()
                input.remove(s)
server.close() 